<?php

/**
 * This is the model class for table "refraction_od".
 *
 * The followings are the available columns in table 'refraction_od':
 * @property integer $id
 * @property string $ar_sph
 * @property string $ar_cyl
 * @property string $ar_axis
 * @property string $manifest_sph
 * @property string $manifest_cyl
 * @property string $manifest_axis
 * @property string $cyrefraction_sph
 * @property string $cyrefraction_cyl
 * @property string $cyrefractionaxis
 * @property string $overrefraction_sph
 * @property string $overrefraction_cyl
 * @property string $overrefraction_axis
 * @property string $w_sph
 * @property string $w_cyl
 * @property string $w_axis
 * @property integer $rx_id
 * @property integer $personalinfo_id
 *
 * The followings are the available model relations:
 * @property Rx $rx
 * @property PersonalInformation $personalinfo
 */
class RefractionOd extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return RefractionOd the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'refraction_od';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('rx_id, personalinfo_id', 'numerical', 'integerOnly'=>true),
			array('ar_sph, ar_cyl, ar_axis, manifest_sph, manifest_cyl, manifest_axis, cyrefraction_sph, cyrefraction_cyl, cyrefractionaxis, overrefraction_sph, overrefraction_cyl, overrefraction_axis, w_sph, w_cyl, w_axis', 'length', 'max'=>5),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, ar_sph, ar_cyl, ar_axis, manifest_sph, manifest_cyl, manifest_axis, cyrefraction_sph, cyrefraction_cyl, cyrefractionaxis, overrefraction_sph, overrefraction_cyl, overrefraction_axis, w_sph, w_cyl, w_axis, rx_id, personalinfo_id', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'rx' => array(self::BELONGS_TO, 'Rx', 'rx_id'),
			'personalinfo' => array(self::BELONGS_TO, 'PersonalInformation', 'personalinfo_id'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'ar_sph' => 'Ar Sph',
			'ar_cyl' => 'Ar Cyl',
			'ar_axis' => 'Ar Axis',
			'manifest_sph' => 'Manifest Sph',
			'manifest_cyl' => 'Manifest Cyl',
			'manifest_axis' => 'Manifest Axis',
			'cyrefraction_sph' => 'Cyrefraction Sph',
			'cyrefraction_cyl' => 'Cyrefraction Cyl',
			'cyrefractionaxis' => 'Cyrefractionaxis',
			'overrefraction_sph' => 'Overrefraction Sph',
			'overrefraction_cyl' => 'Overrefraction Cyl',
			'overrefraction_axis' => 'Overrefraction Axis',
			'w_sph' => 'W Sph',
			'w_cyl' => 'W Cyl',
			'w_axis' => 'W Axis',
			'rx_id' => 'Rx',
			'personalinfo_id' => 'Patient Name',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('ar_sph',$this->ar_sph,true);
		$criteria->compare('ar_cyl',$this->ar_cyl,true);
		$criteria->compare('ar_axis',$this->ar_axis,true);
		$criteria->compare('manifest_sph',$this->manifest_sph,true);
		$criteria->compare('manifest_cyl',$this->manifest_cyl,true);
		$criteria->compare('manifest_axis',$this->manifest_axis,true);
		$criteria->compare('cyrefraction_sph',$this->cyrefraction_sph,true);
		$criteria->compare('cyrefraction_cyl',$this->cyrefraction_cyl,true);
		$criteria->compare('cyrefractionaxis',$this->cyrefractionaxis,true);
		$criteria->compare('overrefraction_sph',$this->overrefraction_sph,true);
		$criteria->compare('overrefraction_cyl',$this->overrefraction_cyl,true);
		$criteria->compare('overrefraction_axis',$this->overrefraction_axis,true);
		$criteria->compare('w_sph',$this->w_sph,true);
		$criteria->compare('w_cyl',$this->w_cyl,true);
		$criteria->compare('w_axis',$this->w_axis,true);
		$criteria->compare('rx_id',$this->rx_id);
		$criteria->compare('personalinfo_id',$this->personalinfo_id);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
	public function getFName()
        {       
        return $this->personal_information['FullName']; 
        }
}